<template>
  <view class="service-container">
    <service-work-stats
	  :title-left="true"
	  title="我的报修"
	  :pending-count="25"
	  :completed-count="25"
	  :show-income="false"
	/>
    <service-work-grid :serviceItems="serviceItems" @itemClick="serviceItemClick"></service-work-grid>
	
	<service-work-company 
	    :teamList="teamList"
	    @contact="handleContact"
	  />
	
	
	<tabbar ref="tab" :activeIndex="activeTab" @popLogin="popLogin"></tabbar>
	<service-agreeement ref="agreementPopup" @confirm="agreementConfirm" />
  </view>
</template>

<script setup>
import { ref,onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'


const activeTab = ref(null)
const agreementPopup = ref(null)
// const switchTab = (index) => {
// 	console.log('服务界面' + index) 
// 	activeTab.value = index
// }
const popLogin = () => {
	agreementPopup.value.open()
}

onShow(() => {
	console.log('服务界面 show') 
	activeTab.value = 1
})
const agreementConfirm = ()=>{

}

onMounted(() => {
	uni.hideTabBar()
	console.log('gvr-service onMounted')
})


const serviceItems = ref([
  { title: '加油机', icon: '/static/service/service-jyj.png', type: 'gas' },
  { title: '在线监测', icon: '/static/service/service-zxjc.png', type: 'monitor' },
  { title: '二次回收', icon: '/static/service/service-ech.png', type: 'recycle' },
  { title: '潜油泵', icon: '/static/service/service-qyb.png', type: 'pump' },
  { title: '液位仪', icon: '/static/service/service-ywy.png', type: 'level' },
  { title: '三次回收', icon: '/static/service/service-sch.png', type: '3recycle' },
  { title: '后台管理系统', icon: '/static/service/service-htg.png', type: 'background' },
  { title: '油管及管道测漏系统', icon: '/static/service/service-ygj.png', type: 'youtube' },
  { title: '其他', icon: '/static/service/service-other.png', type: 'other' }
])

const serviceItemClick = (item) => {
  uni.navigateTo({
    url: `/pages/gvr-service/create-repair?title=${item.title}&&type=${item.type}`
  })
}

const teamList = ref([
  {
    id: 1,
    name: '北京凯瑞嘉禾科技有限责任公司',
    description: '长期加盟合作通信商'
  },
  {
    id: 2,
    name: '北京凯瑞嘉禾科技有限责任公司1',
    description: '长期加盟合作通信商1'
  }
])

const handleContact = (team) => {
  // 处理联系逻辑

  
}


</script>

<style>
.service-container {
  min-height: 100vh;
  background-color: #F5F5F5;
  padding: 0 20rpx;
  padding-top: 30rpx;
  padding-bottom: calc(120rpx + 244rpx + env(safe-area-inset-bottom));
}

</style> 